<template>
    <el-button type="text" size="mini" :disabled="props.disabled" @click.stop="handleDelete()">
        删除
    </el-button>
</template>

<script setup>
    import { defineProps ,defineEmits } from 'vue';
    import { ElMessage, ElMessageBox } from 'element-plus'
    import { deleteSeries } from "@/api/series/series";

    const props = defineProps({
        row: {
            type: Object,
            required: true
        },
        disabled: {
            type: Boolean,
            default: false
        },
    })
    const emit = defineEmits(['reloadSeries'])
    const handleDelete = () => {
        ElMessageBox.confirm(
            '确定删除 ' + props.row.name + ' 吗？',
            '媒资子集删除',
            {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }
        ).then(() => {
            deleteSeries({ seriesid: props.row.seriesid }).then(response => {
                if (response.errcode == 0) {
                    ElMessage({ type: 'success', message: response.msg, duration: 2000 })
                    emit('reloadSeries')
                } else {
                    console.log(response)
                }
            })
        }).catch((err) => {
            console.log(err)
        })
    }
</script>

<style scoped  lang="scss">

</style>